<extend name="base/Base" />
<block name="Style">
<!-- FooTable Plugin CSS -->
		<link rel="stylesheet" type="text/css" href="__ABSOLUTEADMIN__/vendor/plugins/footable/css/footable.core.min.css">
		<!-- Admin Forms CSS -->
		<link rel="stylesheet" type="text/css" href="__ABSOLUTEADMIN__/assets/admin-tools/admin-forms/css/admin-forms.css">
		
</block>
<block name="Topbar">
 <header id="topbar" class="ph10">
        <div class="topbar-left">
          <ul class="nav nav-list nav-list-topbar pull-left">
            <li>
              <a href="#"  data-toggle="modal" data-target="#myModal" >新增菜单</a>
            </li>
            <li  class="active" >
              <a  href="#"   >菜单管理</a>
            </li>
           
          </ul>
        </div>
        <div class="topbar-right hidden-xs hidden-sm">
		 <a href="#"  onclick="selectAll()" class="btn btn-default btn-sm fw600 ml10">
            <span class="fa fa-star pr5"></span>全选</a>
			 <a href="#"   onclick="unSelect()"  class="btn btn-default btn-sm fw600 ml10">
            <span class="fa fa-star-o pr5"></span>不选</a>
			 <a href="#"    onclick="reverse()"class="btn btn-default btn-sm fw600 ml10">
            <span class="fa fa-star-half-o pr5"></span>反选</a>
			  
			
			
			  <a href="#" onclick="status(0)" class="btn btn-default btn-sm fw600 ml10">
				<span class="fa fa-trash-o pr5"></span>删除</a>
			 
						  
          
        </div>
      </header>
      
</block>
<block name="Content">
	 <!-- begin: .tray-center -->
        <div class="row">

        <!-- Panel with: Data Filter -->
          <div class="col-md-12" id="spy2" >
            <div class="panel-heading">
              <span class="panel-title">
                <span class="fa fa-search"></span>菜单信息</span>
               <div class="pull-right">
			 				
            <!--    <a  href="#" data-toggle="modal" data-target="#myModal" class="btn btn btn-primary">新增菜单</a>						
								
							 -->	<!-- Modal -->
									<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
									  <div class="modal-dialog" role="document">
										<div class="modal-content">
										  <div class="modal-header">
											<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
											<h4 class="modal-title" id="myModalLabel">新增菜单</h4>
										  </div>
										  <div class="modal-body">
										    <form class="form-horizontal" role="form">
					
				<div class="form-group">
                    <label for="inputStandard" class="col-lg-3 control-label" style="padding-top:0px;">菜单名称</label>
                    <div class="col-lg-8"  style="padding-top:2px;">
                      <div class="">
                        <input type="text" name="name" id="name" class="form-control input-lg" placeholder="请输入菜单名称">
                      </div>
                    </div>
                  </div>
				 
				  
                
				
                  <div class="form-group">
                    <label for="inputStandard" class="col-lg-3 control-label" style="padding-top:0px;">菜单链接</label>
                    <div class="col-lg-8"  style="padding-top:2px;">
                      <div class="">
                        <input type="text" name="url" id="url" class="form-control input-lg" placeholder="请输入菜单链接">
                      </div>
                    </div>
                  </div>
				  
				 
				   <div class="form-group">
				   <label for="inputSelect" class="col-lg-3 control-label" style="padding-top:0px;">链接类型</label>
					 
				 <label class="radio-inlines" style="padding-left:10px;">
				  <input type="radio" name="type" value="1" checked> 内部链接
					</label>
					<label class="radio-inlines" style="padding-left:10px;">
					  <input type="radio" name="type"  value="4"> 操作行为
					</label>
					<label class="radio-inlines" style="padding-left:10px;">
					  <input type="radio" name="type"  value="2">外部链接
					</label>
					<label class="radio-inlines" style="padding-left:10px;">
					  <input type="radio" name="type"  value="3">小组标识
					</label>
				</div>
				
				
				
				  <div class="form-group">
                    <label for="inputStandard" class="col-lg-3 control-label" style="padding-top:0px;">菜单图标</label>
                    <div class="col-lg-6"  style="padding-top:2px;">
                      <div class="">
                        <input type="text" name="icon" id="icon" class="form-control input-lg" placeholder="请输入菜单图标" >
                      </div>
                    </div>
					<a  target="_blank" href="/public/static/absoluteadmin/ui_icons.html"><span class="fa fa-exclamation-circle">怎么填？</a></span>
                  </div>
				   <div class="form-group">
                    <label for="inputStandard" class="col-lg-3 control-label" style="padding-top:0px;">菜单排序</label>
                    <div class="col-lg-8"  style="padding-top:2px;">
                      <div class="">
                        <input type="number" name="sort" id="sort"  class="form-control input-lg" placeholder="请输入菜单排序">
                      </div>
                    </div>
                  </div>
				  
				   <div class="form-group">
				   <label for="inputSelect" class="col-lg-3 control-label" style="padding-top:0px;">打开方式</label>
					 
				 <label class="radio-inlines" style="padding-left:10px;">
				  <input type="radio" name="target" value="1" checked> 当前页面
					</label>
					<label class="radio-inlines" style="padding-left:10px;">
					  <input type="radio" name="target"  value="2"> 新页面
					</label>
					
				</div>
                </form>
              			
						
										  </div>
										  <div class="modal-footer">
											<button type="button" class="btn btn-default" data-dismiss="modal">关闭页面</button>
											<a href="#" class="btn btn-primary" onclick="create()" >新增菜单</a>
											
										  </div>
										</div>
									  </div>
									</div>
								<script>
						
							//新增菜单
							function create(){  
							
								var name = $("#name").val();
								var url = $("#url").val();
								var type = $("input[name='type']:checked").val();
								var icon = $("#icon").val();
								var sort = $("#sort").val();
								var target = $("input[name='target']:checked").val();;
								
								$.ajax({
									type:'POST',
									url:"__APP__/Admin/Menu/Create.html",
									data:{
										
										"fmid": {$fmid},
										"tier": {$tier},
										"name": name,
										"url": url,
										"icon": icon,
										"type": type,
										"sort": sort,
										"target": target,
										
									},
									success:function(data){			
										var info = eval(data)
										if (info.errcode == 0) {
										
											layer.msg(info.errmsg);
											setTimeout(window.location.reload(),3000);
											
										}else{
											layer.msg(info.errmsg);
										}
									},
									error:function(){
										layer.msg('系统繁忙,请稍候重试！');
									}
								
								});	 
							}  
							
							function AJAXDelete(id){  
								if(confirm('是否确认删除')){
									$.ajax({
										type:'POST',
										url:"__APP__/AICMF/Menu/Value/Delete.html",
										data:{
											"id": id,
											
										},
										success:function(data){								
											if (data == 1) {
											alert('删除成功');
											window.location.reload();
											}else{
												alert(data);
											}
										},
										error:function(){
											alert('未知错误');
										}
									
									});	 
								}
							} 
							
							function AJAXOutage(id){  
								if(confirm('是否确认隐藏')){
									$.ajax({
										type:'POST',
										url:"__APP__/AICMF/Menu/Value/Outage.html",
										data:{
											"id": id,
											
										},
										success:function(data){								
											if (data == 1) {
											alert('隐藏成功');
											window.location.reload();
											}else{
												alert(data);
											}
										},
										error:function(){
											alert('未知错误');
										}
									
									});	 
								}
							} 
							
							function AJAXEnabled(id){  
								if(confirm('是否确认显示')){
									$.ajax({
										type:'POST',
										url:"__APP__/AICMF/Menu/Value/Enabled.html",
										data:{
											"id": id,
											
										},
										success:function(data){								
											if (data == 1) {
											alert('显示成功');
											window.location.reload();
											}else{
												alert(data);
											}
										},
										error:function(){
											alert('未知错误');
										}
									
									});	 
								}
							} 
							</script>
							
              </div> 
            </div>
            <div class="panel-menu">
              <input id="fooFilter" type="text" class="form-control" placeholder="请输入搜索的关键字">
            </div>
            <div class="panel-body pn">
              <table class="table footable" data-filter="#fooFilter"  data-page-navigation=".pagination" data-page-size="100">
               <thead>
												<tr>
													
													<th style="width:4%;">批量</th>
													<th >#</th>
												
													<th >上层</th>
													<th>菜单</th>
													<th>层级</th>
													<th>图标</th>
													
													<th >类型</th>
													<th >链接</th>
													<th >打开</th>
													<th >排序</th>
													 <th >API</th>
													
													<th data-hide="phone,tablet">编辑</th>
												</tr>
											</thead>
											<tbody>
												<volist name="list" id="list">
												<tr>
													<td class="text-center">
													<if condition="$list.id eq 1"> 
													
													
													<else /> 
													
													<center>
														<label class="option block mn">
														  <input type="checkbox" id="batch" name="batch" value="{$list.id}">
														
														</label>
														</center>
													</if>
													
													  </td>
													<td>{$i}</td>
													<td>
													<if condition="$data.tier eq 1"> 
														<if condition="$list.type neq 3"> 
															|-
														
														<else /> 
														<a href="__APP__/Admin/Menu/Manage/fmid/{$data.fmid}.html">	{$data.name|default="顶级菜单"}</a>
													
														</if>
													
													<else /> 
													<if condition="$list.type neq 3"> 
															|-
														
														<else /> 
														{$data.name|default="顶级菜单"}
													
														</if>
													</if>
													
													
													</td>
													
													<td><a href="__APP__/Admin/Menu/Manage/fmid/{$list.id}.html">{$list.name}</a></td>
													<td>{$list.tier}</td>
													<td><i class="{$list.icon}"></i> {$list.icon}</td>
													
													<td>
													<if condition="$list.type eq 1"> 
													内部链接
													<elseif condition="$list.type eq 2"/> 
													外部连接
													<elseif condition="$list.type eq 4"/> 
													操作行为
													<elseif condition="$list.type eq 3"/> 
													小组组标
													<else />
													未知
													</if>
													</td>
													<td>{$list.url}</td>
													<td>
													<if condition="$list.target eq 1"> 
													当前页面
													<elseif condition="$list.target eq 2"/> 
													新窗口
													
													<else />
													未知
													</if>
													</td>
													<td>{$list.sort}</td>
													 <td>
													
													<a  href="__APP__/Admin/Menu/Api/id/{$list.id}.html" 
													
													class="btn btn-xs btn-success">API</a>
													
													</td>
													
													<td>
													<if condition="$list.id eq 1"> 
													
													
													<else /> 
													
													
													
																	<a  href="#" data-toggle="modal" data-target="#myModal{$list.id}"  class="btn btn-xs btn-primary">编辑</a>
														
																					<!-- Modal -->
									<div class="modal fade" id="myModal{$list.id}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
									  <div class="modal-dialog" role="document">
										<div class="modal-content">
										  <div class="modal-header">
											<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
											<h4 class="modal-title" id="myModalLabel">编辑菜单</h4>
										  </div>
										  <div class="modal-body">
										  
										    <form class="form-horizontal" role="form">
					
				<div class="form-group">
                    <label for="inputStandard" class="col-lg-3 control-label" >菜单名称</label>
                    <div class="col-lg-8"  style="padding-top:2px;">
                      <div class="">
                        <input type="text" name="name" id="name{$list.id}" value="{$list.name}" class="form-control input-lg" placeholder="请输入菜单名称">
                      </div>
                    </div>
                  </div>
				 
				  
                 
                  <div class="form-group">
                    <label for="inputStandard" class="col-lg-3 control-label">菜单链接</label>
                    <div class="col-lg-8"  style="padding-top:2px;">
                      <div class="">
                        <input  type="text" name="url" id="url{$list.id}" value="{$list.url}" class="form-control input-lg" placeholder="请输入菜单链接">
                      </div>
                    </div>
                  </div>
				  
				  <div class="form-group">
                    <label for="inputSelect" class="col-lg-3 control-label" >链接类型</label>
                    <div class="col-lg-8" style="padding-top:2px;">
                      <div class="">
                        <select name="type{$list.id}" id="type{$list.id}" class="form-control input-lg">
                  
						  <option value="{$list.type}">保持不变</option>
						  <option value="1">内部链接</option>
						  <option value="4">操作行为</option>
						  <option value="2">外部链接</option>
						  <option value="3">小组标识</option>
                        </select>
                      </div>
                    </div>
                  </div>
				  
				  <div class="form-group">
                    <label for="inputStandard" class="col-lg-3 control-label" >菜单图标</label>
                    <div class="col-lg-8"  style="padding-top:2px;">
                      <div class="">
                        <input type="text" name="icon" id="icon{$list.id}"value="{$list.icon}" class="form-control input-lg" placeholder="请输入菜单图标">
                      </div>
                    </div>
                  </div>
				   <div class="form-group">
                    <label for="inputStandard" class="col-lg-3 control-label">菜单排序</label>
                    <div class="col-lg-8"  style="padding-top:2px;">
                      <div class="">
                        <input type="number" name="sort" id="sort{$list.id}" value="{$list.sort}" class="form-control input-lg" placeholder="请输入菜单排序">
                      </div>
                    </div>
                  </div>
				   <div class="form-group">
                    <label for="inputSelect" class="col-lg-3 control-label" >打开方式</label>
                    <div class="col-lg-8" style="padding-top:2px;">
                      <div class="">
                        <select name="target{$list.id}" id="target{$list.id}" class="form-control input-lg">
                  
						  <option value="{$list.target}">保持不变</option>
						  <option value="1">当前窗口</option>
						  <option value="2">新窗口</option>
						 
                        </select>
                      </div>
                    </div>
                  </div>
                </form>		
						
													<script>
						
							
							function AJAXEdit{$list.id}(id){  
								var sort = $("#sort{$list.id}").val();
								var type = $("#type{$list.id}").val();
								var name = $("#name{$list.id}").val();
								var url = $("#url{$list.id}").val();
								var icon = $("#icon{$list.id}").val();
								var target = $("#target{$list.id}").val();
								
								$.ajax({
									type:'POST',
									url:"__APP__/Admin/Menu/Edit.html",
									data:{
										"id": id,
										"sort": sort,
										"name": name,
										"url": url,
										"type": type,
										"icon": icon,
										"target": target,
									
									},
									success:function(data){			
										var info = eval(data)
										if (info.errcode == 0) {
										
											layer.msg(info.errmsg);
											setTimeout(window.location.reload(),3000);
											
										}else{
											layer.msg(info.errmsg);
										}
									},
								
								});	 
							}  
							
							
						</script> 			
						
										  </div>
										  <div class="modal-footer">
											<button type="button" class="btn btn-default" data-dismiss="modal">关闭页面</button>
											<a href="#" class="btn btn-primary" onclick="AJAXEdit{$list.id}({$list.id})" >编辑菜单</a>
											</form>	
										  </div>
										</div>
									  </div>
									</div>
								
														
													
													
														
														</if>
													</td>
												</tr>
												</volist>
											</tbody>
											 <tfoot class="footer-menu">
												<tr>
												  <td colspan="12">
													<nav class="text-right">
													  <ul class="pagination hide-if-no-paging"></ul>
													</nav>
												  </td>
												</tr>
											  </tfoot>

										</table>
            </div>
          </div>
		      
      </div>

		
</block>
<block name="Script">
	
  <!-- FooTable Plugin -->
  <script src="__ABSOLUTEADMIN__/vendor/plugins/footable/js/footable.all.min.js"></script>
   <!-- FooTable Addon -->
  <script src="__ABSOLUTEADMIN__/vendor/plugins/footable/js/footable.filter.min.js"></script>
  
 <script type="text/javascript">
 
	
		function unSelect(){
				
		  $("input[id='batch']").each(function(){
		   $(this).prop("checked",false);
		  });  
		  
	
		}
		
		function selectAll(){
				
		 $("input[id='batch']").each(function(){
		   $(this).prop("checked",true);
		  });  
		  
		}
		
		function reverse(){
				
		 $("input[id='batch']").each(function(){
			$(this).prop("checked",!this.checked);   
		  
			})
		}
		
					function status(status){
				
				
						 var id=$('input[id="batch"]:checked').map(function(){return this.value}).get().join();
						
						layer.confirm('你确定要这样做么？', {
						  btn: ['确定','取消'] //按钮
						}, function(){
						  
						  $.ajax({
								type:'POST',
								url:"__APP__/Admin/Menu/Delete.html",
								data:{
									
									"id": id,
									"status": status,
									
								},
								success:function(data){			
										var info = eval(data)
										if (info.errcode == 0) {
										
											layer.msg(info.errmsg);
											setTimeout(window.location.reload(),3000);
											
										}else{
											layer.msg(info.errmsg);
										}
								},
								error:function(){
									layer.msg('系统繁忙,请稍候重试！');
								}
							
							});	 
						  
						}, function(){
						  
						  
						});

					
				
				}
				
		  </script>
 <script type="text/javascript">
  jQuery(document).ready(function() {

 

    // Init FooTable Examples
    $('.footable').footable();


  });
  </script>
</block>